#include "plugin/plugin_tinyxml/plugin_tinyxml.h"
 
int main(int argc, char* argv[])
{
        std::string xml_file = "test.xml";
        util::IConfigReader* config_reader = plugin::create_config_reader();
        if (!config_reader->load(xml_file))
        {
                fprintf(stderr, "Cannot load %s.\n", xml_file.c_str());
                exit(2);
        }
 
        std::string value1;
        std::string path1 = "/A/B/C";
        std::string name1 = "name";
        if (config_reader->get_string_value(path1, name1, value1))
                fprintf(stdout, "%s:%s -> %s.\n", path1.c_str(), name1.c_str(), value1.c_str());
        else
                fprintf(stderr, "Cannot get value of %s:%s.\n", path1.c_str(), name1.c_str());
 
        uint32_t value2;
        std::string path2 = "/A/B/C";
        std::string name2 = "age";
        if (config_reader->get_uint32_value(path1, name2, value2))
                fprintf(stdout, "%s:%s -> %u.\n", path2.c_str(), name2.c_str(), value2);
        else
                fprintf(stderr, "Cannot get value of %s:%s.\n", path2.c_str(), name2.c_str());
 
        std::string path3 = "/A/B/C";
        std::string name31 = "name";
        std::string name32 = "age";
        std::vector<uint32_t> age_values3;
        std::vector<std::string> name_values3;
        if (config_reader->get_string_values(path3, name31, name_values3))
        {
                if (config_reader->get_uint32_values(path3, name32, age_values3))
                {
                        if (age_values3.size() == name_values3.size())
                        {
                                fprintf(stdout, "%s:%s/%s ->\n", path3.c_str(), name31.c_str(), name32.c_str());
                                for (std::vector<std::string>::size_type i=0; i<name_values3.size(); ++i)
                                {
                                        fprintf(stdout, "\t%s/%u\n", name_values3[i].c_str(), age_values3[i]);
                                }
                        }
                        else
                        {
                                fprintf(stderr, "%s:%s not match %s:%s.\n", path3.c_str(), name31.c_str(), path3.c_str(), name32.c_str());
                        }
                }
                else
                {
                        fprintf(stderr, "Cannot get value of %s:%s.\n", path3.c_str(), name32.c_str());
                }
        }
        else
        {
                fprintf(stderr, "Cannot get value of %s:%s.\n", path3.c_str(), name32.c_str());
        }
 
        return 0;
}
